<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta charset="UTF-8">
    <title>test template</title>
    <script type="text/javascript" src="../static/template.js"></script>
</head>
<body>
<div id="app"></div>
<script type="text/html" id="test">
<div>
    {{if c == 100}}
    <ul>
        {{each person}}
        <li>姓名：{{$value.name}} -- 性别：{{show($value.sex)}}</li>
        {{/each}}
    </ul>
    {{/if}}
</div>
</script>
<script type="text/javascript">
    var data = {
        c:100,
        person:[
            {name:"jack",age:18,sex:1},
            {name:"tom",age:19,sex:0},
            {name:"jerry",age:20,sex:0},
            {name:"kid",age:21,sex:1},
            {name:"jade",age:22,sex:0},
            {name:"lrving",age:23,sex:1},
        ]
    };
    //自定义函数
    template.helper('show',function (sex) {
        console.log(sex);
        if(sex == 0){
            return '男';
        }else if(sex == 1){
            return '女';
        }
    });
    var html = template('test',data);
    document.getElementById('app').innerHTML = html;

</script>
</body>
</html>